package com.dlc.apk.utils

import java.lang.StringBuilder

object TimeUtil {
    /**
     * 秒倒计时 转成 xx分钟xx秒
     */
    fun convertCountDownToString(countDownSeconds: Int): String {
        val units = arrayOf("分钟", "秒")
        val rates = arrayOf(60, 1)

        val str = StringBuilder()
        var countDownSecondsTemp = countDownSeconds
        rates.forEachIndexed { index, v ->
            val t = countDownSecondsTemp / v
            if (t > 0) {
                str.append(t.toString() + units[index])
                countDownSecondsTemp %= v
            }
        }
        return str.toString()
    }
}